package com.yaglyf.mvc.dao.mapper;

import com.yaglyf.mvc.aop.cache.Cache;
import com.yaglyf.mvc.aop.cache.CacheClear;
import com.yaglyf.mvc.dao.entity.UserInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.cache.annotation.CacheConfig;

@Mapper
@CacheConfig(cacheNames = "user")
public interface UserInfoMapper {
    public final  String  BaseResultMap = "com.yaglyf.mvc.dao.mapper.UserInfoMapper.BaseResultMap";
    public final  String BaseResult  =  "user_id  userId, user_name userName,user_password userPassword," +
                                            "user_email userEmail,salt salt,role_id roleId,is_init isInit,is_delete isDelete," +
                                            "create_time createTime,update_time updateTime,note note";
    @CacheClear
    int deleteByPrimaryKey(Integer userId);
    @CacheClear
    int insert(UserInfo record);
    @CacheClear
    int insertSelective(UserInfo record);
    @Cache
    UserInfo selectByPrimaryKey(Integer userId);
    @CacheClear
    int updateByPrimaryKeySelective(UserInfo record);
    @CacheClear
    int updateByPrimaryKey(UserInfo record);
    @Cache
    @Select("select "+BaseResult+" from user_info where user_name = #{name}")
    UserInfo getUserByName(String name);

}